<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.crm.util.SESSION"%>
<%@ page import="com.crm.po.Users"%>
<%
	String path = request.getContextPath();
	Object obj = request.getSession(true).getAttribute(SESSION.USER_SESSION_KEY);
	Users users = null;
	String iframeLink = "noneAuth.jsp"; 
	if(obj != null){
		users = (Users) obj;
	}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>  
    <title>CRM</title>
    <link rel="icon" mce_href="<%=path%>/images/title_logo.ico" href="<%=path%>/images/title_logo.ico" type="image/x-ico"/>
    <link rel="shortcut icon" mce_href="<%=path%>/images/title_logo.ico" href="<%=path%>/images/title_logo.ico" type="image/x-ico"/>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
	<link rel="stylesheet" type="text/css" href="<%=path%>/css/crm.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/js/easyui1.3.2/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=path%>/js/easyui1.3.2/themes/icon.css">	
	<script type="text/javascript" src="<%=path%>/js/easyui1.3.2/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/easyui1.3.2/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/easyui1.3.2/jquery.easyui.validatebox.rules.js?1=111"></script>
	<script type="text/javascript" src="<%=path%>/js/easyui1.3.2/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="<%=path%>/js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript">

	function setIframe(url){
		if(url != null){
			$("#mainFrame").attr("src", url);
		}		
	}

	//修改个人信息
	function doUpdateInfo(uid){
		$.ajax({
			url : '<%=path%>/user.do?method=getUsersById',
			type : 'POST',
			data : {uid : uid},
			success : function(data) {
				if(data.uid == null){
					$.messager.alert('提示', data, 'info');
				}else{
					$('#userSaveOrUpdate').dialog({  
						title: '修改',  
						width: 600,
						height: 230,
						closed: false,  
						cache: false,   
						modal: true,
						onClose:function(){
							$('.validatebox-tip').remove();
						}
					});
					$('#userSaveOrUpdateForm').form('load',{
						uid: data.uid,
						username: data.username,			
						nickname: data.nickname,
						pwd: data.pwd,
						pwd1: data.pwd,
						tel: data.tel,
						phone: data.phone,
						email: data.email,
						sex: data.sex
					});	
				}		
			}
		});
	}

	//退出
	function logout(){
		$.ajax({
			url : '<%=path%>/user.do?method=logout',
			type : 'POST',
			success : function(data) {
				window.location.href = "<%=path%>/none/index.jsp";
			}
		});
	}

	//执行修改个人信息
	function exeUpdate(){		
		$("#userSaveOrUpdateForm").form('submit', { 
	        url: '<%=path%>/user.do?method=updateSelfInfo',	        
			success:function(data){
				if('ok' == data){
					$('#userSaveOrUpdate').dialog('close');		
					$.messager.alert('提示', '您的个人信息修改成功，将会在您下次登陆时生效。', 'info');
				}else{
					$.messager.alert('提示', data, 'info');
				}
			},
			error : function() {
			
			}
		});
	}

	//打开系统配置对话框
	function systemConfig(){
		$('#systemConfig').dialog({  
			title: '系统配置',  
			width: 500,
			height: 300,
			closed: false,  
			cache: false,   
			modal: true,
			onClose:function(){
				$("#conFrame").attr("src", "");
			}
		});	
		$("#conFrame").attr("src", "conlist.jsp");
	}
	</script>
	<style type="text/css">
		body,td,th,div{
 			font-size:12px;
		}
	</style>
  </head>
  
  <body style="margin:0;padding:0" class="easyui-layout" onload="javascript:setIframe();">
	<div data-options="region:'north',border:false" style="height:75px;padding:0px;overflow:hidden;">
		<table border="0" cellpadding="0" cellspacing="0" bordercolor="red" width="100%" height="100%" style="padding:0px;">
		<tr class="top">
			<td width="600px" height="50px" class="header-left">
								
			</td>
			<td class="header-right">
				欢迎您：<%=users.getNickname()%>&nbsp;&nbsp;&nbsp;&nbsp;<a class="top" href="javascript:doUpdateInfo('<%=users.getUid()%>')">修改我的信息</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="top" href="javascript:logout()">退出</a>					
			</td>
		</tr>
		<tr>
			<td colspan="3" class="title-bar">
			  <%
			  if(users.getCusAuth() != null && users.getCusAuth().indexOf("AUTH_R") >= 0){
			  		if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "cusManage.jsp"; }
			  %>
			  	  <a id="cusManage.jsp" href="javascript:setIframe('cusManage.jsp');" class="easyui-linkbutton" data-options="plain:true">供应商管理</a>
			  <%
			  }
			  if(users.getInvAuth() != null && users.getInvAuth().indexOf("AUTH_R") >= 0){
			  		if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "invManage.jsp"; }
			  %>
			  	  <a id="invManage.jsp" href="javascript:setIframe('invManage.jsp');" class="easyui-linkbutton" data-options="plain:true">增票客户</a>
			  <%	  
			  }
			  if(users.getInvppAuth() != null && users.getInvppAuth().indexOf("AUTH_R") >= 0){
			  		if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "invppManage.jsp"; }
			  %>
			  	  <a id="invppManage.jsp" href="javascript:setIframe('invppManage.jsp');" class="easyui-linkbutton" data-options="plain:true">普票客户</a>
			  <%	  
			  }
			  if(users.getBuyAuth() != null && users.getBuyAuth().indexOf("AUTH_R") >= 0){
			 	 	if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "buyManage.jsp"; }
			  %>
			  	  <a id="buyManage.jsp" href="javascript:setIframe('buyManage.jsp');" class="easyui-linkbutton" data-options="plain:true">采购管理</a>
			  <%	  
			  }
			  if(users.getKcAuth() != null && users.getKcAuth().indexOf("AUTH_R") >= 0){
			  		if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "kcManage.jsp"; }
			  %>
			  	  <a id="kcManage.jsp" href="javascript:setIframe('kcManage.jsp');" class="easyui-linkbutton" data-options="plain:true">库存管理</a>
			  <%	  
			  }
			  if(users.getFp1Auth() != null && users.getFp1Auth().indexOf("AUTH_R") >= 0){
			  		if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "fp1Manage.jsp"; }
			  %>
			  	  <a id="fp1Manage.jsp" href="javascript:setIframe('fp1Manage.jsp');" class="easyui-linkbutton" data-options="plain:true">汇款明细发票</a>
			  <%	  
			  }
			  if(users.getFp2Auth() != null && users.getFp2Auth().indexOf("AUTH_R") >= 0){
			  		if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "fp2Manage.jsp"; }
			  %>
			  	  <a id="fp2Manage.jsp" href="javascript:setIframe('fp2Manage.jsp');" class="easyui-linkbutton" data-options="plain:true">供应商发票</a>
			  <%	  
			  }
			  if(users.getIncomeAuth() != null && users.getIncomeAuth().indexOf("AUTH_R") >= 0){
			  		if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "incomeManage.jsp"; }
			  %>
			  	  <a id="incomeManage.jsp" href="javascript:setIframe('incomeManage.jsp');" class="easyui-linkbutton" data-options="plain:true">销售收入管理</a>
			  <%	  
			  }
			  if(users.getOfferAuth() != null && users.getOfferAuth().indexOf("AUTH_R") >= 0){
			  		if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "offerManage.jsp"; }
			  %>
			  	  <a id="offerManage.jsp" href="javascript:setIframe('offerManage.jsp');" class="easyui-linkbutton" data-options="plain:true">报价单管理</a>
			  <%	  
			  }
			  if("admin".equalsIgnoreCase(users.getUsername())){
			  		if("noneAuth.jsp".equalsIgnoreCase(iframeLink)){ iframeLink = "userManage.jsp"; }
			  %>
			  	  <a id="userManage.jsp" href="javascript:setIframe('userManage.jsp');" class="easyui-linkbutton" data-options="plain:true">用户管理</a>
				  <a href="javascript:systemConfig();" class="easyui-linkbutton" data-options="plain:true">系统配置</a>
			  <%	
			  }
			  %>
			</td>
		</tr>
		</table>
	</div>
	<div data-options="region:'south',border:false" class="bottom">
		<span style="color:#FFFFFF">Copyright@2014 苏州科莱宝五金机械有限公司 K.L.B Inc</span>
	</div>
	<div data-options="region:'center',border:false" style="overflow:hidden;">
		<iframe id="mainFrame" name="mainFrame" frameborder="0" src="<%=iframeLink%>" width="100%" height="100%" scrolling="no"></iframe>
	</div>
	
	<!-- 修改个人信息面板 -->
	<div id="userSaveOrUpdate" class="easyui-dialog" closed="true" data-options="buttons:'#buttonsSaveOrUpdate'" style="padding-top:10px;padding-right:10px;overflow:hidden">
	    <form id="userSaveOrUpdateForm" name="userSaveOrUpdateForm" action="" method="post">
	    	<input type="hidden" id="uid" name="uid" value="">
	    	<table border="0" bordercolor="red">
				<tr height="30px">
	    			<td width="60px" align="right">用户名称</td>
	    			<td width="220px">
	    				<input style="width:200px;background-color:#C0C0C0" class="easyui-validatebox" type="text" id="username" name="username" readOnly/><font color="red">*</font>	
	    			</td>
	    			<td width="60px" align="right">昵称</td>
	    			<td width="220px"><input style="width:200px" class="easyui-validatebox" type="text" id="nickname" name="nickname" data-options="required:true,validType:['length[0,20]']"/><font color="red">*</font></td>
	    		</tr>
	    		<tr height="30px">
	    			<td align="right">密码</td>
	    			<td><input style="width:200px" class="easyui-validatebox" type="password" id="pwd" name="pwd" data-options="required:true,validType:['length[6,20]']"/><font color="red">*</font></td>
	    			<td align="right">确认密码</td>
	    			<td><input style="width:200px" class="easyui-validatebox" type="password" id="pwd1" name="pwd1" data-options="required:true,validType:['samepwd[\'pwd\']']"/><font color="red">*</font></td>
	    		</tr>
	    		<tr height="30px">
	    			<td align="right">固定电话</td>
	    			<td><input style="width:200px" class="easyui-validatebox" type="text" id="tel" name="tel" data-options="validType:['length[0,100]']"/></td>
	    			<td align="right">移动电话</td>
	    			<td><input style="width:200px" class="easyui-validatebox" type="text" id="phone" name="phone" data-options="validType:['length[0,100]']"/></td>
	    		</tr>
	    		<tr height="30px">
	    			<td align="right">电子邮箱</td>
	    			<td><input style="width:200px" class="easyui-validatebox" type="text" id="email" name="email" data-options="validType:'email'"/></td>
	    			<td align="right">性别</td>
	    			<td>
	    				<input type="radio" id="sexMan" name="sex" value="男"/>男&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	    				<input type="radio" id="sexWoman" name="sex" value="女"/>女
	    			</td>
	    		</tr>
	    	</table>
	    </form>
	</div>
	<div id="buttonsSaveOrUpdate" style="display:none">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:exeUpdate()">保存</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#userSaveOrUpdate').dialog('close');">关闭</a>
	</div>
	
		
	<!-- 系统配置面板 -->
	<div id="systemConfig" class="easyui-dialog" closed="true" data-options="buttons:'#buttonsSystemConfig'" style="padding-top:0px;padding-right:0px;overflow:hidden">
	    <iframe id="conFrame" name="conFrame" frameborder="0" src="" width="100%" height="100%" scrolling="no"></iframe>
	    <!--
	    <form id="systemConfigForm" name="systemConfigForm" action="" method="post">
	    	<table border="0" bordercolor="red">
				<tr height="30px">
	    			<td width="60px" align="right">税率&nbsp;&nbsp;</td>
	    			<td>
	    				<input style="width:100px;" class="easyui-numberbox" type="text" id="taxrate" name="taxrate" data-options="precision:2" value="0.00"/>	
	    			</td>
	    		</tr>
	    	</table>
	    </form>
	    -->
	</div>
	<div id="buttonsSystemConfig" style="display:none">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#systemConfig').dialog('close');">关闭</a>
	</div>
	
  </body>
</html>
